<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
</body>
<script>
  let hd = '14j34j2b4b12b'
  let a = '2b'
  let b = '3b'
  //eval将字符串转换为代码执行
  console.log(eval(`/${a}/`).test(hd))//true
  console.log(eval(`/${b}/`).test(hd))//false

  //测试
  let str = 'abcdefg12345hijk'
  console.log(/\d/.test(str))//true
  console.log(/fg/.test(str))//true
</script>
</html>